package com.yazi.mxz.mobile.controller.user;

import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myframework.smhj.jackson.result.ObjectResult;
import com.yazi.mxz.common.entity.beans.ShoppingCart;
import com.yazi.mxz.mobile.jackson.filter.ShoppingCartFilter;


@Controller("user-shoppingCartController")
@RequestMapping("/user/shoppingCart")
public class ShoppingCartController extends BaseController {
	private static Logger log = LoggerFactory.getLogger(ShoppingCartController.class);
	
	@RequestMapping
	public String index(Model model) {
		log.debug("进入购物车页面");
		
		Set<ShoppingCart> shoppingCarts = getMember().getShoppingCarts();
		model.addAttribute("shoppingCarts", shoppingCarts);
		return "v1.5/user/shoppingCart";
	}
	
	@RequestMapping("/list/json")
	@ResponseBody
	public ObjectResult<Set<ShoppingCart>> listJson() {
		ObjectResult<Set<ShoppingCart>> jsonResult = new ObjectResult<Set<ShoppingCart>>();
		jsonResult.setFilter(ShoppingCartFilter.get4List());
		jsonResult.setResult(getMember().getShoppingCarts());
		jsonResult.setOk();
		return jsonResult;
	}
	
}
